#ifndef ALIYUN_CLIENT
#define ALIYUN_CLIENT
#include "./I_TDDNS_Client.h"
#include <ESP8266HTTPClient.h>
#include <WiFiClient.h>
#include "ESPDateTime.h"
#include <UrlEncode.h>
#include <ArduinoJson.h>
#include "sha1.h"
class AliyunClient : public I_TDDNS_Client
{
public:
    AliyunClient(String secretId,String secretKey,WiFiClient *wc, String subDomain);
   
    String getCurrentIp();

    bool isNeedChange(String &currentIp, String &oldIp);
    bool updateRecord(String &currentIp);
    void getCurrentTimeAndNonce(String &timeS, String &nonce);
    void getUpdateParams(String &AccessKeyId, String &recordId, String &subDomain, String &nonce, String &timestamp, String &ip, String &str);
    void getRecordParams(String &AccessKeyId, String &subDomain, String &nonce, String &timestamp, String &str);
    String aliUrlEncode(String &content);
    void getSignStr(String &content, String &signStr);
    void getPublicIp(String &ip);
    void updateRecord(String &recordId, String &ip, String &subDomain);
    void getRecordId(String &recordId);
    void sign(String &content, String &sig);

private:
    WiFiClient *wifiClient;
    uint8_t *in, out, i;

    unsigned long currentTime = 0L;
    static char b64chars[];
    unsigned long startTime, t;
    char b64[29];
    String recordId;
};

#endif